﻿using CalligraphyEditor.CalligraphyData;
using CalligraphyEditor.ViewModel;
using DevExpress.Xpf.Grid;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace CalligraphyEditor
{
    /// <summary>
    /// Interaction logic for DevRubbingPhotos.xaml
    /// </summary>
    public partial class DevRubbingPhotos : Page,IPage
    {
        VMRubbingPhotos _vm;
        public DevRubbingPhotos(T_Rubbing r)
        {
            InitializeComponent();
            _vm = new VMRubbingPhotos(r);
            this.Gcl_RubbingPhotos.DataContext = _vm.Cvs;
        }
        private void view_CellValueChanged(object sender, CellValueChangedEventArgs e)
        {
            Save();
        }
        public bool Editable
        {
            get { return true; }
        }

        public string Path
        {
            get { return string.Empty; }
        }

        public void Add()
        {
            string errorMsg =  _vm.Upload();
            if (!string.IsNullOrEmpty(errorMsg))
            {
                MessageBox.Show(errorMsg,"错误",MessageBoxButton.OK,MessageBoxImage.Error);
            }
        }

        public void Delete()
        {
            _vm.Delete();
        }

        public void Save()
        {
            _vm.Save();
        }
         
        public event EventHandler<NavigateToPageEventArgs> NavigateToPage;

        private void Gcl_RubbingPhotos_AsyncOperationStarted(object sender, RoutedEventArgs e)
        {

        }
    }
}
